//
//  RHWindowTipManage.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2023/7/5.
//

#import "RHWindowTipManage.h"
#import "RHNavigationController.h"

@interface RHWindowTipManage()

@property (nonatomic ,strong) UIWindow *window;

@property (nonatomic ,strong) RHBaseViewController *controller;

@property (nonatomic ,strong) RHNavigationController *navController;

@end

@implementation RHWindowTipManage

- (instancetype)init{
    
    self = [super init];
    if (self) {
        _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        [_window setBackgroundColor:[UIColor clearColor]];
        UIViewController *controller = [[UIViewController alloc] init];
        [_window setRootViewController:controller];
        [_window makeKeyAndVisible];
        UIWindow *minWindow = [UIApplication sharedApplication].delegate.window;
        [minWindow addSubview:_window];
        [_window setHidden:YES];
    }
    
    return self;
}

+ (RHWindowTipManage *)shareWindowTipManage{
    static id sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedInstance = [[self alloc] init];
    });
    return sharedInstance;
}


- (void)showWithController:(RHBaseViewController *)controller{
    self.controller = controller;
    [_window setFrame:[[UIScreen mainScreen] bounds]];
    [_window setRootViewController:self.controller];
    [_window setHidden:NO];
    UIWindow *minWindow = [UIApplication sharedApplication].delegate.window;
    [minWindow bringSubviewToFront:_window];
}

- (void)showWithNavController:(UINavigationController *)controller{
    self.navController = controller;
    [_window setRootViewController:self.navController];
    [_window setHidden:NO];
}

- (void)showWithLoginController{

    [_window setHidden:NO];
}

- (void)hidden{
    [_window setHidden:YES];
}


@end
